package com.lswms.modules.lswms.service.impl.stock;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lswms.common.service.impl.CrudServiceImpl;
import com.lswms.modules.lswms.dao.stock.TradeDao;
import com.lswms.modules.lswms.dto.stock.TradeDTO;
import com.lswms.modules.lswms.entity.stock.TradeEntity;
import com.lswms.modules.lswms.service.stock.TradeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 属性
 *
 * @author DX sunlightcs@gmail.com
 * @since 1.0.0 2021-06-14
 */
@Service
public class TradeServiceImpl extends CrudServiceImpl<TradeDao, TradeEntity, TradeDTO> implements TradeService {

    @Override
    public QueryWrapper<TradeEntity> getWrapper(Map<String, Object> params){

        String id = (String)params.get("id");
        String sku = (String)params.get("sku");
        String qty = (String)params.get("qty");
        String fromlot = (String)params.get("fromlot");
        String tolot = (String)params.get("tolot");
        String fromlocation = (String)params.get("fromlocation");
        String tolocation = (String)params.get("tolocation");
        String fromtray = (String)params.get("fromtray");
        String totray = (String)params.get("totray");
        String frombox = (String)params.get("frombox");
        String tobox = (String)params.get("tobox");
        String tradetype = (String)params.get("tradetype");

        QueryWrapper<TradeEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);
        wrapper.eq(StringUtils.isNotBlank(sku), "sku", sku);
        wrapper.eq(StringUtils.isNotBlank(qty), "qty", qty);
        wrapper.eq(StringUtils.isNotBlank(fromlot), "fromlot", fromlot);
        wrapper.eq(StringUtils.isNotBlank(tolot), "tolot", tolot);
        wrapper.eq(StringUtils.isNotBlank(fromlocation), "fromlocation", fromlocation);
        wrapper.eq(StringUtils.isNotBlank(tolocation), "tolocation", tolocation);
        wrapper.eq(StringUtils.isNotBlank(fromtray), "fromtray", fromtray);
        wrapper.eq(StringUtils.isNotBlank(totray), "totray", totray);
        wrapper.eq(StringUtils.isNotBlank(frombox), "frombox", frombox);
        wrapper.eq(StringUtils.isNotBlank(tobox), "tobox", tobox);
        wrapper.eq(StringUtils.isNotBlank(tradetype), "tradetype", tradetype);
        
        wrapper.orderByDesc("addtime");

        return wrapper;
    }


}